package com.rudolphliu.dao;

import com.rudolphliu.entity.Users;
import org.apache.ibatis.jdbc.SQL;

public class UsersSqlProvider {

    public String insertSelective(Users record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("users");
        
        if (record.getUid() != null) {
            sql.VALUES("uid", "#{uid,jdbcType=VARCHAR}");
        }
        
        if (record.getNameTitle() != null) {
            sql.VALUES("name_title", "#{nameTitle,jdbcType=VARCHAR}");
        }
        
        if (record.getNameFirst() != null) {
            sql.VALUES("name_first", "#{nameFirst,jdbcType=VARCHAR}");
        }
        
        if (record.getNameLast() != null) {
            sql.VALUES("name_last", "#{nameLast,jdbcType=VARCHAR}");
        }
        
        if (record.getEmail() != null) {
            sql.VALUES("email", "#{email,jdbcType=VARCHAR}");
        }
        
        if (record.getUsername() != null) {
            sql.VALUES("username", "#{username,jdbcType=VARCHAR}");
        }
        
        if (record.getPassword() != null) {
            sql.VALUES("password", "#{password,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            sql.VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getPictureLarge() != null) {
            sql.VALUES("picture_large", "#{pictureLarge,jdbcType=VARCHAR}");
        }
        
        if (record.getPictureMedium() != null) {
            sql.VALUES("picture_medium", "#{pictureMedium,jdbcType=VARCHAR}");
        }
        
        if (record.getPictureThumbnail() != null) {
            sql.VALUES("picture_thumbnail", "#{pictureThumbnail,jdbcType=VARCHAR}");
        }
        
        if (record.getNat() != null) {
            sql.VALUES("nat", "#{nat,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Users record) {
        SQL sql = new SQL();
        sql.UPDATE("users");
        
        if (record.getNameTitle() != null) {
            sql.SET("name_title = #{nameTitle,jdbcType=VARCHAR}");
        }
        
        if (record.getNameFirst() != null) {
            sql.SET("name_first = #{nameFirst,jdbcType=VARCHAR}");
        }
        
        if (record.getNameLast() != null) {
            sql.SET("name_last = #{nameLast,jdbcType=VARCHAR}");
        }
        
        if (record.getEmail() != null) {
            sql.SET("email = #{email,jdbcType=VARCHAR}");
        }
        
        if (record.getUsername() != null) {
            sql.SET("username = #{username,jdbcType=VARCHAR}");
        }
        
        if (record.getPassword() != null) {
            sql.SET("password = #{password,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            sql.SET("phone = #{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getPictureLarge() != null) {
            sql.SET("picture_large = #{pictureLarge,jdbcType=VARCHAR}");
        }
        
        if (record.getPictureMedium() != null) {
            sql.SET("picture_medium = #{pictureMedium,jdbcType=VARCHAR}");
        }
        
        if (record.getPictureThumbnail() != null) {
            sql.SET("picture_thumbnail = #{pictureThumbnail,jdbcType=VARCHAR}");
        }
        
        if (record.getNat() != null) {
            sql.SET("nat = #{nat,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("uid = #{uid,jdbcType=VARCHAR}");
        
        return sql.toString();
    }
}